package com.lihao.wanandroid.ui.home.plaza

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.lihao.jetpackcore.base.BaseViewModel
import com.lihao.wanandroid.R
import com.lihao.wanandroid.data.model.ArticleResponse
import com.lihao.wanandroid.data.model.PlazaResponse

/**
 * Created by lihao on 2020/6/12.
 * Describe:
 */
class PlazaAdapter : BaseQuickAdapter<ArticleResponse, BaseViewHolder>(R.layout.item_plaza),
    LoadMoreModule {

    init {
        addChildClickViewIds(R.id.tvCollect)
    }

    override fun convert(holder: BaseViewHolder, item: ArticleResponse) {
        item.run {
            holder.setText(
                R.id.tvAuthor,
                if (author != null && author.isEmpty()) shareUser else author
            )
            holder.setGone(R.id.tvFresh, !fresh)
            holder.setGone(R.id.tvStick, type != 1)
            holder.setText(R.id.tvCollect, if (collect) "已收藏" else "+ 收藏")
            holder.setTextColorRes(
                R.id.tvCollect,
                if (collect) R.color.tagColorGray else R.color.colorPrimary
            )
            holder.setText(R.id.tvTitle, title)
            holder.setText(R.id.tvTime, niceDate)
        }
    }
}